home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / tutil.arc / LIB002.INC < prev    next >
Encoding:
Text File  |  1980-01-01  |  2.1 KB  |  79 lines

  1. {.HE LIB002.INC                 Date, Time Functions                  Page #}
  2. {.FO                             Last Update of LIB002.INC : 07-09-84    DJS}
  3. {File : LIB002.INC           }
  4. { For : Turbo Pascal         }
  5. {  By : David J. Smith       }
  6. {Date : 07-09-84             }
  7.  
  8. type TimeString = String[8];
  9.  
  10. Function time: TimeString;
  11.  
  12. {This Function will return the system time as a string in the form
  13.   HH:MM:SS.  Military format.  The Result is of type String[8]}
  14.  
  15. type
  16.   regpack = record
  17.               ax,bx,cx,dx,bp,di,si,ds,es,flags: integer;
  18.             end;
  19.  
  20. var
  21.   recpack:          regpack;             {assign record}
  22.   ah,al,ch,cl,dh:   byte;
  23.   hour,min,sec:     string[2];
  24.  
  25. begin
  26.   ah := $2c;                             {initialize correct registers}
  27.   with recpack do
  28.   begin
  29.     ax := ah shl 8 + al;
  30.   end;
  31.   intr($21,recpack);                     {call interrupt}
  32.   with recpack do
  33.   begin
  34.     str(cx shr 8,hour);                  {convert to string}
  35.     str(cx mod 256,min);                       { " }
  36.     str(dx shr 8,sec);                         { " }
  37.   end;
  38.   if length(min) < 2 then min := '0' + min;
  39.   if length(sec) < 2 then sec := '0' + sec;
  40.   if length(hour) < 2 then hour := '0' + hour;
  41.   time := hour+':'+min+':'+sec
  42. end;
  43.  
  44.  
  45. type DateStr = string[10];
  46.  
  47. function Date: DateStr;
  48.  
  49. {The Date function will return a string of the type String[10] in the
  50.   form MM-DD-YYYY.}
  51.  
  52. type
  53.   regpack = record
  54.               ax,bx,cx,dx,bp,si,ds,es,flags: integer;
  55.             end;
  56.  
  57. var
  58.   recpack:       regpack;                {record for MsDos call}
  59.   month,day:     string[2];
  60.   year:          string[4];
  61.   dx,cx:         integer;
  62.  
  63. begin
  64.   with recpack do
  65.   begin
  66.     ax := $2a shl 8;
  67.   end;
  68.   MsDos(recpack);                        { call function }
  69.   with recpack do
  70.   begin
  71.     str(cx,year);                        {convert to string}
  72.     str(dx mod 256,day);                     { " }
  73.     str(dx shr 8,month);                     { " }
  74.   end;
  75.   if Length(month) < 2 then month := '0' + month;
  76.   if Length(day)   < 2 then day   := '0' + day;
  77.   date := month+'/'+day+'/'+year;
  78. end;
  79.